home *** CD-ROM | disk | FTP | other *** search
/ Interactive Web Graphics with Shout 3D / Interactive Web Graphics With Shout 3D.iso / mac / Code / Chapter10 / MultiViewpointsGUIApplet.java < prev    next >
Text File  |  2000-09-08  |  2KB  |  66 lines

  1.  
  2.  
  3. package applets;
  4.  
  5. import  shout3d.*;
  6. import java.awt.*;
  7.  
  8.  
  9. public class MultiViewpointsGUIApplet extends Shout3DApplet {
  10.  
  11.    int total = 1;
  12.    Button newcam;
  13.    Choice list;
  14.    Panel bottomPanel;
  15.    
  16.    
  17.    public void initShout3DPanel(){
  18.       panel = new MultiViewpointsGUIPanel(this, 320, 210);
  19.  
  20.        setLayout(new BorderLayout());
  21.       newcam = new Button("NEW CAMERA");
  22.       list = new Choice();
  23.       list.addItem("Camera "+ total);
  24.       bottomPanel = new Panel();
  25.       bottomPanel.add(newcam);
  26.       bottomPanel.add(list);   
  27.       add(bottomPanel, "South");
  28.    }
  29.    
  30.    
  31.    public boolean action(Event e, Object o) {
  32.    
  33.       //user pressed button;
  34.       //calls createCamera() in panel class
  35.       if (e.target == newcam) {
  36.       
  37.          MultiViewpointsGUIPanel pnl = (MultiViewpointsGUIPanel) panel;
  38.          pnl.createCamera();
  39.          total = pnl.totalCams;
  40.          list.addItem("Camera "+ total);
  41.          
  42.          //call select to update list
  43.          list.select(total - 1);
  44.          
  45.          //disable button, if necessary
  46.          if(total == 3) {newcam.enable(false);}   
  47.          return true;     
  48.       }
  49.       
  50.       //user selects from list
  51.       if (e.target == list) {
  52.       
  53.          int i = list.getSelectedIndex();
  54.          MultiViewpointsGUIPanel pnl = (MultiViewpointsGUIPanel) panel;
  55.          pnl.currentCam  =  i + 1;
  56.          pnl.cameras[i].isBound.setValue(true);
  57.          return true;     
  58.       }
  59.  
  60.       return false; 
  61.  
  62.    }//end of action method
  63.  
  64.    
  65.    
  66. }//end of class